local sk__yingge = fk.CreateSkill {

  name = "sk__yingge",

  tags = {  },

}



sk__yingge:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__yingge.name) and target.phase == Player.Play and not player:isKongcheng() and not target.dead
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, false, sk__yingge.name, true, ".", "#sk__yingge-invoke::"..target.id, true)
    if #card > 0 then
      event:setCostData(self, card)
      player.room:doIndicate(player.id, {target.id})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = Fk:getCardById(event:getCostData(self)[1]).number
    room:throwCard(event:getCostData(self), sk__yingge.name, player, player)
    if not target.dead then
      room:setPlayerMark(target, "@sk__yingge-phase", n)
      room:addPlayerMark(target, MarkEnum.SlashResidue.."-phase", n)
    end
  end,
})

sk__yingge:addEffect("prohibit", {
  name = "#sk__yingge_prohibit",
  prohibit_use = function(self, player, card)
    return player:getMark("@sk__yingge-phase") > 0 and card.number < player:getMark("@sk__yingge-phase")
  end,
})

sk__yingge:addEffect("filter", {
  name = "#sk__yingge_filter",
  mute = true,
  card_filter =function (self, card, player, isJudgeEvent)
     return player:getMark("@sk__yingge-phase") > 0 and card.number >= player:getMark("@sk__yingge-phase") and
      table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, player,to_select)
    local card = Fk:cloneCard("slash", to_select.suit, to_select.number)
    card.skillName = "sk__yingge"
    return card
  end,
})

sk__yingge:addEffect("atkrange", {
  name = "#sk__yingge_attackrange",
  correct_func = function (self, from, to)
    return from:getMark("@sk__yingge-phase")
  end,
})

return sk__yingge